package controler;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import model.SimulationSettings;

public class GuiListener implements ActionListener{

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource()==MonteCarlo.mainFrame.start)
		{
			
			MonteCarlo.settings.orderType=(String) MonteCarlo.mainFrame.orderTypeCombo.getSelectedItem();
			MonteCarlo.settings.currentPrice = (double) MonteCarlo.mainFrame.currentPriceSpin.getValue();
			MonteCarlo.settings.strikePrice = (double) MonteCarlo.mainFrame.strikePriceSpin.getValue();
			MonteCarlo.settings.fees = (double) MonteCarlo.mainFrame.feesSpin.getValue();
			MonteCarlo.settings.interest = (double) MonteCarlo.mainFrame.interestSpin.getValue();
			MonteCarlo.settings.timeMaturity = (double) MonteCarlo.mainFrame.timeMaturitySpin.getValue();
			MonteCarlo.settings.volatility = (double) MonteCarlo.mainFrame.volatilitySpin.getValue();
			MonteCarlo.settings.steps = (double) MonteCarlo.mainFrame.stepsSpin.getValue();
			MonteCarlo.settings.simulation = (double) MonteCarlo.mainFrame.simulationSpin.getValue();
			

			
			MonteCarlo.mySimulation.setOptions(MonteCarlo.settings);
			MonteCarlo.myMultiThreadSimulation.setOptions(MonteCarlo.settings);
			
			
			
			MonteCarlo.myMultiThreadSimulation.myCall();
			MonteCarlo.mySimulation.run();
			//System.out.println(MonteCarlo.mySimulation.result);
			MonteCarlo.resFrame.displayResult(MonteCarlo.mySimulation.result);
		}
		
		if(e.getSource()==MonteCarlo.resFrame.okButton)
		{
			MonteCarlo.resFrame.setVisible(false);
			
		}
		
	}
	

}
